<template>
  <!-- 语言切换 -->
  <el-dropdown trigger="click" @command="handleSetLanguage">
    <div>
      <svg-icon class-name="language-icon" icon-class="language" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item
        v-for="item of languageOptions"
        :key="item.value"
        :command="item.value"
      >
        {{ item.label }}
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>
<script>
export default {
  data () {
    return {
      languageOptions: [
        { label: '中文简体', value: 'zh' },
        { label: 'English', value: 'en' },
        { label: '中文繁體', value: 'hk' }
      ]
    }
  },
  methods: {
    handleSetLanguage (lang) {
      this.$i18n.locale = lang
      // console.log(this.$i18n.locale)
      localStorage.setItem('languageval', lang)
      this.$message({
		showClose: true,
        message: this.$t('message.setLang'),
        type: 'success'
      })
    }
  }
}
</script>
